<!-- <if condition="$Think.get.leads eq 'leads'">
	<div id="leads_id" style="display:none;">{$Think.get.id}</div>
</if> -->
<style>
    .owner{
        pointer-events: none;
    }
</style>
<div class="clearfix">
	<!--<form class="form-inline" id="dd" action="{:U('user/listdialog')}">-->
		<input type="hidden" name="m" value="user"/>
		<input type="hidden" name="a" value="listdialog"/>
		<if condition = "$_GET['leads'] eq 'leads'">
			<input type="hidden" name="leads" value="leads"/>
			<input type="hidden" name="id" id="leads_id" value="{$_GET['id']}"/>
		</if>
		<ul class="nav pull-left form-inline">
			<li class="pull-left">
				<select style="width:auto;" class="form-control" name="d_department" id="d_department" >
					<option class="all" value="all">{:L('ALL')}</option>
					<volist name="departmentList" id="vo">
						<option value="{$vo.department_id}" <if condition = "$search_field['d_department'] eq $vo['department_id']">selected</if> >{$vo.name}</option>
					</volist>
				</select>&nbsp;&nbsp;
			</li>
			<li class="pull-left">
				<input class="form-control" id="d_name" type="text" name="d_name" value="{$search_field['d_name']}" placeholder="{:L('USER_NAME')}" onkeydown="if(event.keyCode==13)changeCondition1(0)"/>&nbsp;&nbsp;
			</li>
			<li class="pull-left">
				<input type="hidden" name="by" id="dialog_by" value="{$by}"/>
				<input type="button" onclick="changeCondition1(0);return false;" class="btn btn-primary" value="{:L('SEARCH')}"/>
			</li>
		</ul>
	<!--</form>-->
</div>
<if condition="$role_list">
	<table class="table table-hover">
		<thead>
			<tr>
				<th>&nbsp;</th>
				<th>{:L('STAFF')}</th>
				<th>{:L('DEPARTMENT')}</th>
				<th>{:L('POSITION')}</th>
				<th>{:L('SEX')}</th>
				<!--<th>Email</th>-->
				<!--<th>{:L('TELPHONE')}</th>-->
			</tr>
		</thead>
		<tfoot id="footers">
			<tr>
				<td colspan="7">
					{$page}
				</td>
			</tr>
		</tfoot>
		<tbody id="data2">
			<if condition="role_list neq null">
				<volist name="role_list" id="vo">
					<tr style="cursor:pointer">
						<td>
							<div class="checkbox checkbox-info checkbox-inline" style="margin-left:15px;">
								<input name="owner" class="owner" type="radio" rel="{$vo['user_name']}" rel2="{$vo['img']}" value="{$vo.role_id}"><label for=""></label>
							</div>
						</td>
						<td>{$vo.user_name}</td>
						<td>{$vo.department_name}</td>
						<td>{$vo.role_name}</td>
						<td><if condition="$vo['sex'] eq 1">{:L('MALE')}<elseif condition="$vo['sex'] eq 2"/>{:L('FEMALE')}</if></td>
						<!--<td>{$vo.email}</td>-->
						<!--<td>{$vo.telephone}</td>-->
					</tr>
				</volist>
			<else />
				<tr>
					<td>{:L('EMPTY_DATA')}</td>
				</tr>
			</if>
		</tbody>
	</table>
<else />
	<div style="clear:both">
		<include file="Public:nodata" />
	</div>
</if>
<script type="text/javascript">
	$('#go_page').change(function(){
		var sel = $(this).val();
		$('#dialog-role-list2').load(sel);
		return false;
	});
	$(function(){
		$('#footers a').click(function(){
            var joiner = new Array();
            var joiner_name = new Array();
            $('input:checkbox[name="owner"]:checked').each(function () {
                joiner.push($(this).val());
                joiner_name.push($(this).attr('rel'));
            })
            joiner = joiner.join(",");
            joiner_name = joiner_name.join(",");
//            sessionStorage.setItem("key", joiner_name);
//            var data = sessionStorage.getItem('key');
            var rel = $(this).attr('href');
			$('#dialog-role-list2').load(rel);
			return false;
		});
	});

    var ids=ids?ids:[];
    var names=names?names:[];
	$("#data2 tr").click(function(){
        var _this=$(this).find('td:first-child .owner');
        if(_this.prop('checked')){
            $('#data2').find('.owner').prop('checked', false);
            sessionStorage.setItem('idskey', '');
            sessionStorage.setItem('nameskey', '');
        }else{
            $('#data2').find('.owner').prop('checked', false);
            ids=_this.val();
            names=_this.attr('rel');
            sessionStorage.setItem('nameskey', names);
            sessionStorage.setItem('idskey', ids);
            _this.prop('checked', true);
        }
	});
	function changeCondition1(){
		var department = $('#d_department option:selected').val();
		var name = $('#d_name').val();
		name = name.trim();
		var by = $('#dialog_by').val();
		// $('#dialog-role-list2').load('index.php?'+$("#dd").serialize());
		var url = "{:U('user/listdialog','d_department=')}"+department+'&d_name='+name+'&by='+by;
		$('#dialog-role-list2').load(url,function(){
			changeCondition();
		});
		return false;
	}
    var idskey=sessionStorage.getItem("idskey");
    var idsarr=[];
    idsarr=idskey.split(',');
    $('input:checkbox[name=owner]').each(function () {
        var _this=$(this);
        for(var i=0;i<idsarr.length;i++){
            if(_this.val()==idsarr[i]){
                _this.prop('checked', true);
            }
        }
    })

</script>
